package org.huoran.sakamichi.main.controller;

import org.huoran.sakamichi.intf.ITestService;
import org.huoran.sakamichi.main.util.ResultBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;


@Controller
@RequestMapping({"/dubbo"})
public class DubboController {
    @Resource
    private ITestService testServiceImpl;

    @ResponseBody
    @RequestMapping(value = {"/getTestResult/{name}"})
    public ResultBean getUserByUserName(@PathVariable String name) {
        try {
            String testResult = testServiceImpl.getTestResult(name);
            return ResultBean.success(testResult);
        } catch(Exception e) {
            e.printStackTrace();
            return ResultBean.failed("Invoke dubbo failed");
        }
    }
}
